/* Version definitions */
#undef NTDDI_VERSION
#define NTDDI_VERSION NTDDI_VISTA
#undef _WIN32_WINNT
#define _WIN32_WINNT _WIN32_WINNT_VISTA

#include <ntifs.h>
#include <ndk/ntndk.h>

#define C_ASSERT_FIELD(Type, Offset, MemberType, MemberName) \
    C_ASSERT(FIELD_OFFSET(Type, MemberName) == Offset); \
    C_ASSERT(FIELD_SIZE(Type, MemberName) == sizeof(MemberType));

/* KTHREAD */
C_ASSERT_FIELD(KTHREAD, 0x000, DISPATCHER_HEADER, Header)
C_ASSERT_FIELD(KTHREAD, 0x018, ULONG64, CycleTime)
C_ASSERT_FIELD(KTHREAD, 0x020, ULONG64, QuantumTarget)
C_ASSERT_FIELD(KTHREAD, 0x028, PVOID, InitialStack)
C_ASSERT_FIELD(KTHREAD, 0x030, PVOID, StackLimit)
C_ASSERT_FIELD(KTHREAD, 0x038, PVOID, KernelStack)
C_ASSERT_FIELD(KTHREAD, 0x040, ULONG64, ThreadLock)
C_ASSERT_FIELD(KTHREAD, 0x048, KAPC_STATE, ApcState)
C_ASSERT_FIELD(KTHREAD, 0x048, UCHAR[43], ApcStateFill)
C_ASSERT_FIELD(KTHREAD, 0x073, CHAR, Priority)
C_ASSERT_FIELD(KTHREAD, 0x074, USHORT, NextProcessor)
C_ASSERT_FIELD(KTHREAD, 0x076, USHORT, DeferredProcessor)
C_ASSERT_FIELD(KTHREAD, 0x078, ULONG64, ApcQueueLock)
C_ASSERT_FIELD(KTHREAD, 0x080, LONG64, WaitStatus)
C_ASSERT_FIELD(KTHREAD, 0x088, PKWAIT_BLOCK, WaitBlockList)
C_ASSERT_FIELD(KTHREAD, 0x088, PKGATE, GateObject)
C_ASSERT_FIELD(KTHREAD, 0x090, LONG, MiscFlags)
C_ASSERT_FIELD(KTHREAD, 0x094, UCHAR, WaitReason)
C_ASSERT_FIELD(KTHREAD, 0x095, UCHAR, SwapBusy)
C_ASSERT_FIELD(KTHREAD, 0x096, UCHAR[2], Alerted)
C_ASSERT_FIELD(KTHREAD, 0x098, LIST_ENTRY, WaitListEntry)
C_ASSERT_FIELD(KTHREAD, 0x098, SINGLE_LIST_ENTRY, SwapListEntry)
C_ASSERT_FIELD(KTHREAD, 0x0A8, PKQUEUE, Queue)
C_ASSERT_FIELD(KTHREAD, 0x0B0, PVOID, Teb)
C_ASSERT_FIELD(KTHREAD, 0x0B8, KTIMER, Timer)
C_ASSERT_FIELD(KTHREAD, 0x0B8, UCHAR[60], TimerFill)
C_ASSERT_FIELD(KTHREAD, 0x0F4, LONG, ThreadFlags)
C_ASSERT_FIELD(KTHREAD, 0x0F8, KWAIT_BLOCK[4], WaitBlock)
C_ASSERT_FIELD(KTHREAD, 0x0F8, UCHAR[43], WaitBlockFill0)
C_ASSERT_FIELD(KTHREAD, 0x123, UCHAR, IdealProcessor)
C_ASSERT_FIELD(KTHREAD, 0x0F8, UCHAR[91], WaitBlockFill1)
C_ASSERT_FIELD(KTHREAD, 0x153, CHAR, PreviousMode)
C_ASSERT_FIELD(KTHREAD, 0x0F8, UCHAR[139], WaitBlockFill2)
C_ASSERT_FIELD(KTHREAD, 0x183, UCHAR, ResourceIndex)
C_ASSERT_FIELD(KTHREAD, 0x0F8, UCHAR[187], WaitBlockFill3)
C_ASSERT_FIELD(KTHREAD, 0x1B3, UCHAR, LargeStack)
C_ASSERT_FIELD(KTHREAD, 0x0F8, UCHAR[44], WaitBlockFill4)
C_ASSERT_FIELD(KTHREAD, 0x124, ULONG, ContextSwitches)
C_ASSERT_FIELD(KTHREAD, 0x0F8, UCHAR[92], WaitBlockFill5)
C_ASSERT_FIELD(KTHREAD, 0x154, UCHAR, State)
C_ASSERT_FIELD(KTHREAD, 0x155, UCHAR, NpxState)
C_ASSERT_FIELD(KTHREAD, 0x156, UCHAR, WaitIrql)
C_ASSERT_FIELD(KTHREAD, 0x157, CHAR, WaitMode)
C_ASSERT_FIELD(KTHREAD, 0x0F8, UCHAR[140], WaitBlockFill6)
C_ASSERT_FIELD(KTHREAD, 0x184, ULONG, WaitTime)
C_ASSERT_FIELD(KTHREAD, 0x0F8, UCHAR[188], WaitBlockFill7)
C_ASSERT_FIELD(KTHREAD, 0x1B4, SHORT, KernelApcDisable)
C_ASSERT_FIELD(KTHREAD, 0x1B6, SHORT, SpecialApcDisable)
C_ASSERT_FIELD(KTHREAD, 0x1B4, ULONG, CombinedApcDisable)
C_ASSERT_FIELD(KTHREAD, 0x1B8, LIST_ENTRY, QueueListEntry)
C_ASSERT_FIELD(KTHREAD, 0x1C8, PKTRAP_FRAME, TrapFrame)
C_ASSERT_FIELD(KTHREAD, 0x1D0, PVOID, FirstArgument)
C_ASSERT_FIELD(KTHREAD, 0x1D8, PVOID, CallbackStack)
C_ASSERT_FIELD(KTHREAD, 0x1D8, ULONG64, CallbackDepth)
C_ASSERT_FIELD(KTHREAD, 0x1E0, UCHAR, ApcStateIndex)
C_ASSERT_FIELD(KTHREAD, 0x1E1, CHAR, BasePriority)
C_ASSERT_FIELD(KTHREAD, 0x1E2, CHAR, PriorityDecrement)
C_ASSERT_FIELD(KTHREAD, 0x1E3, UCHAR, Preempted)
C_ASSERT_FIELD(KTHREAD, 0x1E4, UCHAR, AdjustReason)
C_ASSERT_FIELD(KTHREAD, 0x1E5, CHAR, AdjustIncrement)
C_ASSERT_FIELD(KTHREAD, 0x1E6, UCHAR, Spare01)
C_ASSERT_FIELD(KTHREAD, 0x1E7, CHAR, Saturation)
C_ASSERT_FIELD(KTHREAD, 0x1E8, ULONG, SystemCallNumber)
C_ASSERT_FIELD(KTHREAD, 0x1EC, ULONG, Spare02)
C_ASSERT_FIELD(KTHREAD, 0x1F0, ULONG64, UserAffinity)
C_ASSERT_FIELD(KTHREAD, 0x1F8, PKPROCESS, Process)
C_ASSERT_FIELD(KTHREAD, 0x200, ULONG64, Affinity)
C_ASSERT_FIELD(KTHREAD, 0x208, PKAPC_STATE[2], ApcStatePointer)
C_ASSERT_FIELD(KTHREAD, 0x218, KAPC_STATE, SavedApcState)
C_ASSERT_FIELD(KTHREAD, 0x218, UCHAR[43], SavedApcStateFill)
C_ASSERT_FIELD(KTHREAD, 0x243, CHAR, FreezeCount)
C_ASSERT_FIELD(KTHREAD, 0x244, CHAR, SuspendCount)
C_ASSERT_FIELD(KTHREAD, 0x245, UCHAR, UserIdealProcessor)
C_ASSERT_FIELD(KTHREAD, 0x246, UCHAR, Spare03)
C_ASSERT_FIELD(KTHREAD, 0x247, UCHAR, CodePatchInProgress)
C_ASSERT_FIELD(KTHREAD, 0x248, PVOID, Win32Thread)
C_ASSERT_FIELD(KTHREAD, 0x250, PVOID, StackBase)
C_ASSERT_FIELD(KTHREAD, 0x258, KAPC, SuspendApc)
C_ASSERT_FIELD(KTHREAD, 0x258, UCHAR, SuspendApcFill0)
C_ASSERT_FIELD(KTHREAD, 0x259, CHAR, Spare04)
C_ASSERT_FIELD(KTHREAD, 0x258, UCHAR[3], SuspendApcFill1)
C_ASSERT_FIELD(KTHREAD, 0x25B, UCHAR, QuantumReset)
C_ASSERT_FIELD(KTHREAD, 0x258, UCHAR[4], SuspendApcFill2)
C_ASSERT_FIELD(KTHREAD, 0x25C, ULONG, KernelTime)
C_ASSERT_FIELD(KTHREAD, 0x258, UCHAR[64], SuspendApcFill3)
C_ASSERT_FIELD(KTHREAD, 0x298, PKPRCB, WaitPrcb)
C_ASSERT_FIELD(KTHREAD, 0x258, UCHAR[72], SuspendApcFill4)
C_ASSERT_FIELD(KTHREAD, 0x2A0, PVOID, LegoData)
C_ASSERT_FIELD(KTHREAD, 0x258, UCHAR[83], SuspendApcFill5)
C_ASSERT_FIELD(KTHREAD, 0x2AB, UCHAR, PowerState)
C_ASSERT_FIELD(KTHREAD, 0x2AC, ULONG, UserTime)
C_ASSERT_FIELD(KTHREAD, 0x2B0, KSEMAPHORE, SuspendSemaphore)
C_ASSERT_FIELD(KTHREAD, 0x2B0, UCHAR[28], SuspendSemaphorefill)
C_ASSERT_FIELD(KTHREAD, 0x2CC, ULONG, SListFaultCount)
C_ASSERT_FIELD(KTHREAD, 0x2D0, LIST_ENTRY, ThreadListEntry)
C_ASSERT_FIELD(KTHREAD, 0x2E0, LIST_ENTRY, MutantListHead)
C_ASSERT_FIELD(KTHREAD, 0x2F0, PVOID, SListFaultAddress)
C_ASSERT_FIELD(KTHREAD, 0x2F8, LONG64, ReadOperationCount)
C_ASSERT_FIELD(KTHREAD, 0x300, LONG64, WriteOperationCount)
C_ASSERT_FIELD(KTHREAD, 0x308, LONG64, OtherOperationCount)
C_ASSERT_FIELD(KTHREAD, 0x310, LONG64, ReadTransferCount)
C_ASSERT_FIELD(KTHREAD, 0x318, LONG64, WriteTransferCount)
C_ASSERT_FIELD(KTHREAD, 0x320, LONG64, OtherTransferCount)
C_ASSERT_FIELD(KTHREAD, 0x328, PVOID, MdlForLockedTeb)

/* KUSER_SHARED_DATA */
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x000, ULONG, TickCountLowDeprecated)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x004, ULONG, TickCountMultiplier)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x008, KSYSTEM_TIME, InterruptTime)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x014, KSYSTEM_TIME, SystemTime)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x020, KSYSTEM_TIME, TimeZoneBias)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x02C, USHORT, ImageNumberLow)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x02E, USHORT, ImageNumberHigh)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x030, WCHAR[260], NtSystemRoot)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x238, ULONG, MaxStackTraceDepth)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x23C, ULONG, CryptoExponent)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x240, ULONG, TimeZoneId)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x244, ULONG, LargePageMinimum)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x248, ULONG[7], Reserved2)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x264, NT_PRODUCT_TYPE, NtProductType)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x268, BOOLEAN, ProductTypeIsValid)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x26C, ULONG, NtMajorVersion)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x270, ULONG, NtMinorVersion)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x274, BOOLEAN[64], ProcessorFeatures)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2B4, ULONG, Reserved1)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2B8, ULONG, Reserved3)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2BC, ULONG, TimeSlip)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2C0, ALTERNATIVE_ARCHITECTURE_TYPE, AlternativeArchitecture)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2C8, LARGE_INTEGER, SystemExpirationDate)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2D0, ULONG, SuiteMask)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2D4, BOOLEAN, KdDebuggerEnabled)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2D5, UCHAR, MitigationPolicies) // NXSupportPolicy
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2D8, ULONG, ActiveConsoleId)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2DC, ULONG, DismountCount)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2E0, ULONG, ComPlusPackage)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2E4, ULONG, LastSystemRITEventTickCount)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2E8, ULONG, NumberOfPhysicalPages)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2EC, BOOLEAN, SafeBootMode)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2F0, ULONG, SharedDataFlags)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x2F8, ULONGLONG, TestRetInstruction)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x300, ULONG, SystemCall)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x304, ULONG, SystemCallReturn)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x320, KSYSTEM_TIME, TickCount)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x320, ULONGLONG, TickCountQuad)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x330, ULONG, Cookie)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x338, ULONGLONG, ConsoleSessionForegroundProcessId)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x340, ULONG[16], Wow64SharedInformation)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x380, USHORT[8], UserModeGlobalLogger)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x390, ULONG[2], HeapTracingPid)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x398, ULONG[2], CritSecTracingPid)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x3A0, ULONG, ImageFileExecutionOptions)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x3A4, ULONG, LangGenerationCount)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x3A8, ULONGLONG, AffinityPad)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x3A8, KAFFINITY, ActiveProcessorAffinity)
C_ASSERT_FIELD(KUSER_SHARED_DATA, 0x3B0, ULONGLONG, InterruptTimeBias)
